import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import { createWebHistory, createRouter, createWebHashHistory } from 'vue-router'
import HomePage from '@/pages/HomePage.vue'
import AboutPage from '@/pages/AboutPage.vue'
import NewsPage from '@/pages/NewsPage.vue'
import News1 from '@/pages/NewsDetail1.vue'
import News2 from '@/pages/NewsDetail2.vue'
//1.配置路由规则
const routes = [
  { path: '/', redirect: '/home' },
  { path: '/home', component: HomePage },
  { path: '/about', component: AboutPage },
  {
    path: '/news',
    component: NewsPage,
    name: 'news',
    children: [
      {
        name: 'xinwen1',
        // Param传参，URL预设占位符，?表示参数可选
        path: '1/:id/:title/:content',
        component: News1,
      },
      {
        name: 'xinwen2',
        path: '2',
        component: News2,
      },
    ],
  },
]
//2.创建路由器
const router = createRouter({
  history: createWebHistory(), //路由工作模式  createWebHashHistory 带#
  routes,
})
//3.加载路由器
const app = createApp(App)
const pinia = createPinia() //创建pinia实例
//引入elment-plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
app.use(router)
app.use(pinia)
app.use(ElementPlus)
app.mount('#app')
